<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<form name="form1" id="form1">
		</form>
		<button onclick="add()">添加</button>
		<script type="text/javascript">
			function add()
			{
				console.log("add()")
				// 1. 创建网页元素
				var txt = document.createElement("input");// input元素 
				// 2. 设置属性
				txt.type = "text";
				txt.value = "小明";
				txt.name = "nickname";
				// 3. 放到页面中某个元素下面
				// 找到form1元素
				// var form1 = document.getElementById("form1");
				form1.appendChild(txt);
				
			}

		</script>

	</body>
</html>
